{* Smarty *}
<div class="box">
	<table cellspacing="0">
		<caption>{t}create a group{/t}</caption>
		<tr>
			<th>{if isset($modify)}{t}modify group{/t}{else}{t}create group{/t}{/if}</th>
		</tr>
		<tr>
			{if isset($result)}
			<td class="success"><a class="success" href="/admin/modules/groups">{if isset($modify)}{t}group modified{/t}{else}{t}group added{/t}{/if}</a></td>
			{else}
			<td class="form">
				<form {$form_data.attributes}>
				<table class="form">
					<tr>
				 	  <td class="form">{$form_data.name.label}</td><td class="form">{$form_data.name.html}</td>
					</tr>
					<tr>
				 	  <td class="form">{$form_data.description.label}</td><td class="form">{$form_data.description.html}</td>
					</tr>
					{if isset($form_data.checkbox)}
					{if isset($form_data.checkbox.error) }
					<tr>
						<td class="form" colspan="2">{$form_data.checkbox.error}</td>
				  </tr>
					{/if}
					<tr>
					  <td class="form" colspan="2">
						<table cellspacing="0">
						  <tr>
							<th colspan="4">{t}existing modules{/t}</th>
						  </tr>
						  {counter start=0 skip=1 assign=count}
						  <tr>
								{foreach item=mod from=$gmodules}
								{assign var="count" value=$count+1}
								<td class="right">{$form_data.checkbox[$mod.id].html}</td>
								<td class="form">
									{t}{$form_data.checkbox[$mod.id].label}{/t}
								</td>
								{if $count == 2}
						  </tr>
						  <tr>
								{assign var="count" value=0}
								{/if}
						    {/foreach}
						  </tr>
						</table>
					</td>
					</tr>
					{/if}
					<tr>
						<td colspan="2" class="right">{$form_data.btn_Submit.label}{$form_data.btn_Submit.html}</td>
					</tr>
					<tr>
					  <td colspan="2" class="center">{$form_data.requirednote}</td>
				  </tr>
				</table>
				</form>
			</td>
			{/if}
		</tr>
	</table>
</div>

{if !isset($modify)}
<div class="box">
	<table cellspacing="0">
		<caption>{t}current groups{/t}</caption>
		<tr>
			<th colspan="4">{t}Groups{/t}</th>
		</tr>
		<tr>
			<th colspan="2" class="left" width="40%">{t}group{/t}</th>
			<th class="left" width="40%">{t}modules{/t}</th>
			<th width="20%">{t}edit{/t}</th>
		</th>
		{foreach item=grp from=$groups name=groups}
		<tr>
			{if $smarty.foreach.groups.total > 1}
			<td class="left" valign="top" width="5%">
				<table class="none">
					<tr>
					{if $smarty.foreach.groups.first}
					<td class="none" colspan="2" valign="top">
						{html_image file="/themes/$template/images/go-down-grey.gif" border="0" href="/admin/modules/groups/gorder/`$grp.id`/down"}
					</td>
					{elseif $smarty.foreach.groups.last}
					<td class="none" colspan="2" valign="top">
						{html_image file="/themes/$template/images/go-up-grey.gif" border="0" href="/admin/modules/groups/gorder/`$grp.id`/up"}
					</td>
					{else}
					<td class="none" width="5%" valign="top">
						{html_image file="/themes/$template/images/go-up-grey.gif" border="0" href="/admin/modules/groups/gorder/`$grp.id`/up"}
					</td>
					<td class="none" width="5%" valign="top">
						{html_image file="/themes/$template/images/go-down-grey.gif" border="0" href="/admin/modules/groups/gorder/`$grp.id`/down"}
					</td>
					{/if}
					</tr>
				</table>
			</td>
			{else}
				<td></td>
			{/if}
			<td class="left" valign="top" width="40%">{$grp.name}<br/><small><i>{$grp.description}</i></small></td>
			<td class="left" valign="top">
				<table class="none">
				{foreach item=mod key=k from=$grp.modules name=modules}
					<tr>
						<td class="none" width="40%">{$mod}</td>
						{if $smarty.foreach.modules.total > 1}
						{if $k==1}
						<td class="none" width="5%"></td>
						<td class="none" valign="top">
							{html_image file="/themes/$template/images/go-down-blue.gif" border="0" href="/admin/modules/groups/order/`$grp.id`/down/`$k`"}
						</td>
						{elseif $smarty.foreach.modules.last}
						<td class="none" width="5%">
							{html_image file="/themes/$template/images/go-up-blue.gif" border="0" href="/admin/modules/groups/order/`$grp.id`/up/`$k`"}
						</td>
						<td class="none"></td>
						{else}
						<td class="none" width="5%">
							{html_image file="/themes/$template/images/go-up-blue.gif" border="0" href="/admin/modules/groups/order/`$grp.id`/up/`$k`"}
						</td>
						<td class="none">
							{html_image file="/themes/$template/images/go-down-blue.gif" border="0" href="/admin/modules/groups/order/`$grp.id`/down/`$k`"}
						</td>
						{/if}
						{/if}
						</td>
					</tr>
				{/foreach}
				</table>
			</td>
			<td valign="top">
				{html_image file="/themes/$template/images/edit.gif" border="0" href="/admin/modules/groups/modify/`$grp.id`"}
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				{html_image file="/themes/$template/images/delete.gif" border="0" href="/admin/modules/groups/delete/`$grp.id`/`$grp.name`"}
			</td>
		</tr>
		{/foreach}
	</table>
</div>
{/if}